<template>
	<view class="page tn-safe-area-inset-bottom" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
		<view class="top-bg"></view>
		<dawnBar title="科室信息"></dawnBar>
		<view class="page-container" style="padding-bottom: 140rpx;">
			<view class="order--wrap">
				<!-- 标签内容 -->
				<view class="list">
					<view class="list-item" v-for="(item,index) in list" :key="index">
						<view class="list-content tn-flex tn-flex-nowrap tn-flex-col-center tn-flex-row-between">
							<view class="tn-flex tn-flex-nowrap  tn-flex-col-center tn-flex-row-left">
								<view v-if="item.coverImg" @click="navLink('/hosp/department/detail?itemId='+item.id)">
									<!-- <tn-avatar shape="square" :text="item.name" size="130rpx"></tn-avatar> -->
									<image mode="aspectFill" class="hosp-image" :src="item.coverImg">
								</view>
								<view class="tn-padding-left-ss">
									<view class="">
										<text class="dawn-text-lg dawn-color">{{ item.name }}</text>
										<text class="tn-color-gray tn-padding-left-xs tn-padding-right-xs">|</text>
										<text @click="callPhoneNumber(item.phone)" class="tn-icon-tel-circle-fill dawn-text-sm tn-margin-right-ss"></text>
										<text @click="callPhoneNumber(item.phone)" class="dawn-text-sm">{{ item.phone || ''}}</text>
									</view>
									<view class="" v-if="item.workRange">
										<text class="tn-icon-time-fill dawn-text-sm tn-margin-right-ss"></text>
										<text class="dawn-text-sm">{{ item.workRange || ''}}</text>
									</view>
									<view class="">
										<text class="tn-icon-map-fill dawn-text-sm tn-margin-right-ss"></text>
										<text class="dawn-text-sm">{{ item.address }}</text>
									</view>
								</view>
							</view>
							<view @click="navLink('/hosp/department/detail?itemId='+item.id)"
								class="tn-flex tn-flex-nowrap  tn-flex-col-center tn-flex-row-left">
								<view class="justify-content-item tn-text-right">
									<text class="tn-icon-right tn-color-gray"></text>
								</view>
							</view>
						</view>

						<view class="dawn-line"></view>
						<view v-if="item.description"
							class=" tn-flex tn-flex-direction-row tn-flex-nowrap tn-flex-col-center tn-flex-row-between">
							<view class="justify-content-item tn-text-df">
								<text class=" tn-text-sm tn-color-gray news-desc">
									{{ item.description }}
								</text>
								<!-- <view class='conters news-desc'>
									<parser :html="item.content" ref="article"></parser>
								</view> -->
							</view>
						</view>
					</view>
				</view>

				<!-- 悬浮按钮-->
				<view class="tn-flex tn-footerfixed">
					<view class="tn-flex-1 justify-content-item tn-margin-sm tn-text-center">
						<tn-button @click="getPage()" class="dawn-btn-lg dawn-btn-lg__main"
							backgroundColor="tn-main-gradient-dawn">
							<text class="tn-icon-search-list-fill tn-padding-right-xs"></text>
							<text>查 询</text>
						</tn-button>
					</view>
				</view>
			</view>
			<view v-if="show">
				<dawnMsg :box="dawnMsgBox" :msg="msg"></dawnMsg>
			</view>
		</view>

		<!-- loading -->
		<dawnLoading :show="loading"></dawnLoading>

		<!-- 分页 -->
		<!-- <dawn-pagination ref="pagination" :current="queryData.pageNo" :total="total" @pagination="getPage" /> -->

		<!-- 悬浮按钮-->
		<NavBtn></NavBtn>
	</view>
</template>

<script>
	import page_mixin from '@/mixins/page_mixin.js'
	import dayjs from '@/plugin/dayjs/dayjs.min.js';
	import * as DepartmentApi from '@/api/cms/department.js';
	import * as api from '@/api/api.js';
	import * as config from "@/api/config.js";
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	const app = getApp();

	export default {
		name: 'order',
		mixins: [page_mixin],
		computed: mapGetters(['appConfig', 'uid', 'isLogin', 'userInfo', 'patientInfo']),
		data() {
			return {
				loading: false,
				show: false,
				msg: '',
				dawnMsgBox: '',
				queryData: {
					pageSize: 10,
					pageNo: 1,
					userId: ''
				},
				list: []
			}
		},
		onLoad(options) {
			this.getPage();
		},
		methods: {
			getPage: function(page) {
				let that = this;
				this.loading = true;
				this.show = false;
				this.dawnMsgBox = '';
				this.$set(this, 'list', []);

				// this.queryData.userId = app.globalData.openid;
				this.queryData.userId = this.userInfo.openid;
				DepartmentApi.getDepartmentList(this.queryData).then(res => {
					this.loading = false;
					console.table(res);
					if (res.code === 0) {
						const l = res.data || [];
						this.$set(this, 'list', l);
						if (l.length == 0) {
							this.show = true;
							this.msg = '暂无数据！';
						}
					} else {
						this.show = true;
						this.msg = res.msg;
					}
				}).catch(err => {
					this.loading = false;
					this.show = true;
				})
			},
			navLink(url) {
				uni.navigateTo({
					url: url
				})
			},
			formatDate: function(date) {
				return dayjs(date).format("YYYY-MM-DD");
			},
			formatDateTime: function(date) {
				return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tn-avatar {
		z-index: 0 !important;
	}
</style>